package de.tum.in.elitese.wahlsys.persister.persistence_objects;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

import de.tum.in.elitese.wahlsys.persister.PersistenceObject;

/**
 * see Table KANDIDATENLISTENRANG
 * 
 * @author Christoph Frenzel
 * 
 */
public class Kandidatenlistenrang extends PersistenceObject {
	private static final List<String> FIELD_NAMES = Collections
			.unmodifiableList(Arrays.asList(new String[] { "KANDIDAT",
					"LANDESLISTE", "PARTEI", "NUMMER" }));

	private static final String TABLE_NAME = "KANDIDATENLISTENRANG";

	private Kandidat fKandidat;

	private Landesliste fLandesliste;

	private Short fNummer;

	public Kandidat getKandidat() {
		return fKandidat;
	}

	public Landesliste getLandesliste() {
		return fLandesliste;
	}

	public Short getNummer() {
		return fNummer;
	}

	@Override
	public List<String> getPersistanceStrings() {
		List<Object> values = new ArrayList<Object>(4);
		values.add(getKandidat().getPersonalausweisnummer());
		values.add(getLandesliste().getId());
		values.add(getLandesliste().getPartei().getName());
		values.add(getNummer());

		List<String> result = new ArrayList<String>(1);
		result.add(createInsertString(TABLE_NAME, FIELD_NAMES, Collections
				.unmodifiableList(values)));
		return result;
	}

	public void setKandidat(Kandidat kandidat) {
		fKandidat = kandidat;
	}

	public void setLandesliste(Landesliste landesliste) {
		fLandesliste = landesliste;
	}

	public void setNummer(Short nummer) {
		fNummer = nummer;
	}
}
